package com.example;

import java.awt.*;
import java.awt.image.BufferedImage;

public class text {
    public static void main(String[] args) {
        BufferedImage image=new BufferedImage(200,50,BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics2D=image.createGraphics();
        graphics2D.setFont(new Font("楷体",Font.BOLD,30));
        graphics2D.drawString("生日快乐",1,image.getHeight()-10);
        int[] arg=image.getRGB(0,0,image.getWidth(),image.getHeight(),
                new int[image.getWidth()* image.getHeight()],0,image.getWidth());
        char[] chars={'生','日','快','乐'};
        int happy=0;
        for(int l=0;l<image.getHeight();l++){
            for (int j=0;j<image.getWidth();j++){
                int h=l*image.getWidth()+j;
                if(arg[h]!=0){
                    System.out.print(chars[happy]);
                    happy=(happy+1)%4;
                }else {
                    System.out.print(" ");
                }
                if(j==image.getWidth()-1){
                    System.out.println();
                }
            }
        }
    }
}
